<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>

<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>科目新增</title>
  <style>
    body {
      margin: 0;
      padding: 0;
      text-align: center;
      background: url("${base}/Desert.jpg");
      background-size: cover;
    }

    #c {
      margin: auto;
      margin-top: 70px;
      opacity: 0.8;
      width: 1000px;
      height: 600px;
    }
    #left {
      width: 700px;
      height: 600px;
      background: rgb(255, 255, 255);
      margin: auto;
      border-radius: 20px;
      padding-top: 10px;
      position: relative;
    }
    input {
      width: 270px;
      border-top-style: hidden;
      border-right-style: hidden;
      border-left-style: hidden;
      background: none;
      margin: 0;
      text-align: center;
    }
    p {
      color: gray;
      height: 30px;
    }
    #file {
      margin-top: 10px;
      color: #616161;
    }
    button {
      margin-top: 50px;
      width: 250px;
      height: 33px;
      border-radius: 20px;
      border: 0px;
      background-color: #c0ca33;
      color: #FFF;
      font-size: 16px;
    }
    span {
      position: absolute;
      left: 30px;
      color: red;
      font-size: 13px;
    }
  </style>
</head>
<body>
<div id="c">
  <div id="left">
    <h1>添加科目</h1>
    <form action="${base}/ttc/add" method="post" enctype="multipart/form-data" onsubmit="return checked()">
      <div id="error" style="display: inline-block"></div>
      <p>科目类型: <input type="text" name="type" id="type" ></p>
      <div style="margin-left: -140px">状态:
        <input type="radio" name="status" value="0" style="width: 30px" checked>已导入
        <input type="radio" name="status" value="1" style="width: 30px;">未导入
      </div>
      <button id="sub" type="submit" >增加</button>
    </form>
  </div>
</div>
<script src="${base}/jquery-3.0.0.min.js"></script>
<script>
  var isExit = false;
  $("#type").blur(function () {
   $.post("${base}/ttc/checkType?type="+$("#type").val(),function (result) {
              if(result == "科目不存在可以添加"){
                isExit = false;
                $("#error").html(result).css("color","green");
              }else {
                isExit = true;
                $("#error").html(result).css("color","red");
              }
   })
  })
  function checked() {
        if(isExit){
          $("#error").html("科目已存在").css("color","red");
        return false;
        }
  }
</script>
</body>
</html>

